"""
地区模型
"""
from sqlalchemy import Column, String, DateTime, func
from sqlalchemy.orm import relationship
from .base import Base


class Region(Base):
    """地区表"""
    __tablename__ = "regions"
    
    name = Column(String(50), nullable=False, comment="地区名称")
    province = Column(String(50), comment="省份")
    city = Column(String(50), comment="城市")
    
    # 关系
    students = relationship("Student", back_populates="region")
    traffic_statistics = relationship("TrafficStatistics", back_populates="region")
    
    def __repr__(self):
        return f"<Region(id={self.id}, name='{self.name}', province='{self.province}')>"
